package heathot.servlet;

import heathot.bookservice.BookService;
import heathot.bookservice.BookServiceimpl;
import heathot.dao.impl.BookDao;
import heathot.dao.impl.BookDaoimpl;
import heathot.entiy.Book;
import heathot.entiy.BookPager;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PageServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			request.setCharacterEncoding("utf-8");
			response.setCharacterEncoding("utf-8");
			String currentPage = request.getParameter("currentPage");
			int currentPageInt = 0;
			if(currentPage!=null&&!"".equals(currentPage)){
				currentPageInt = Integer.parseInt(currentPage);
			}
			BookService service= new BookServiceimpl();
			BookPager bp = service.selectBookByPage(currentPageInt,5);
			request.setAttribute("bp",bp);
			request.getRequestDispatcher("/showbook.jsp").forward(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			doGet(request,response);
		
	}
}
